package com.woniuxy.system.mapper;

import com.woniuxy.system.entity.UrlPermission;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 * 菜单和接口权限定义 Mapper 接口
 * </p>
 *
 * @author 作者
 * @since 2023-10-13
 */
public interface UrlPermissionMapper extends BaseMapper<UrlPermission> {

    @Select("SELECT \n" +
            "  DISTINCT p.*\n" +
            "FROM t_url_permission p\n" +
            "  INNER JOIN t_role_url_permission rp ON p.id=rp.url_permission_id\n" +
            "  INNER JOIN t_manager_role mr ON rp.role_id=mr.role_id\n" +
            "WHERE 1=1\n" +
            "  AND mr.manager_id=#{managerId}")
    List<UrlPermission> findPermissionsByManagerId(Long managerId);
}
